/*
 * @Description: 微信
 * @Author: kanglin
 * @Date: 2018-09-27 09:08:47
 * @Copyright: Created by Panxsoft.
 */
// import errorReport from 'src/utils/error-report';
import Vue from 'vue';
import VueRouter from 'vue-router';
import axios from 'src/utils/axios-interceptors';
import InitData from 'src/utils/initData';	// 初始化数据的类
import API_LIST from 'src/API_LIST';

import { DatetimePlugin, ConfirmPlugin } from 'vux';
import toast from 'cube-ui/lib/toast';
import 'cube-ui/lib/cube.min.css';
/* eslint-disable-next-line */
import 'src/assets/css/common.css';
import { i18n } from 'src/locales';
import router from './router'; // eslint-disable-line
import store from './vuex/store';
import App from './app.vue';

import * as Sentry from '@sentry/browser';
import * as Integrations from '@sentry/integrations';

import StatusManagement from './StatusManagement';	// 状态管理的类
/* eslint-disable no-unused-vars */
// import echarts from 'echarts';
// require('babel-polyfill');
// Vue.config.performance = true;
// errorReport.init();
Vue.use(VueRouter);
Vue.use(DatetimePlugin);
Vue.use(ConfirmPlugin);
Vue.prototype.$http = axios;

// 实例化状态管理的类
const status_management = StatusManagement.getInstance();

// 实例化初始数据的类
const param = {
	openid_url: API_LIST.WECHAT_OPENID,
	user_url: API_LIST.USER_INFO,
	jssdk_url: API_LIST.WECHAT_JSSDK,
	upload_location_url: API_LIST.USER_LOCATION,
	redirect_url: API_LIST.WECHAT_OAUTH,
	switch_lang: true,
};

const initClass = InitData.getInstance(param);

// 把状态管理的类和初始数据的类绑定到vue的原型上，方便使用
Vue.prototype.$status = status_management;

Vue.prototype.$initData = initClass;

Vue.use(toast);


// Toast.succeed('操作成功', 0);
// 网址参数
(function initVue() {
	return new Vue({
		i18n,
		el: '#app',
		router,
		store,
		render: h => h(App),
	});
}());

if (process.env.NODE_ENV === 'production') {
	Sentry.init({
		dsn: 'https://bff11f3bad0441159750a16a2354c95d@sentry.panxsoft.com/12',
		integrations: [new Integrations.Vue({ Vue, attachProps: true })],
	});
}
